    
    WelcomeCtrl.$inject = [
    'merchantService',    
    '$scope',
    '$location',
    '$rootScope',
    '$interval'
    // 'WelcomeService'
    ];

    function WelcomeCtrl(merchantService,$scope, $location,$rootScope,$interval) {
        var vm = this;
        merchantService.findAllAliveMerchants(function(res){
            vm.merchants = res.data;
        });
        $scope.lunboImg = [];
        merchantService.findAds(function(res) {
            console.log(res.data+"ad!!!!!!!!!!!");
            var merchantsAds = res.data;
             for(var i = 1;i<merchantsAds.length;i++){
                 console.log(merchantsAds[i].fimg);
                let temp = {'id':i,'img':merchantsAds[i].food.fimg};
                $scope.lunboImg.push(temp);
             }
            
        })
       vm.findFoodListByIcnum = function(icnum){        
            console.log('click');
            $location.path("/food/"+icnum);
        }
        // $scope.lunboImg = [];
        // $scope.lunboImg.push({ id: 1, img: 'http://www.socwall.com/images/wallpapers/71672-3836x2877.jpg' });
        // $scope.lunboImg.push({ id: 2, img: 'http://www.socwall.com/images/wallpapers/71656-1781x1200.jpg' });
        // $scope.lunboImg.push({ id: 3, img: 'http://www.socwall.com/images/wallpapers/71647-1920x1080.jpg' });

        $scope.lunbo = { 
        	currentId:1
        };
        
        $scope.previousImg = function () {
            if ($scope.lunbo.currentId == 1) {
                $scope.lunbo.currentId = $scope.lunboImg.length;
            }
            else {
                $scope.lunbo.currentId--;
            }
        };
        $scope.nextImg = function () {
            if ($scope.lunbo.currentId == $scope.lunboImg.length) {
                $scope.lunbo.currentId = 1;
            }
            else {
                $scope.lunbo.currentId++;
            }
        };
        $interval(function () {
            if ($scope.lunbo.currentId == $scope.lunboImg.length) {
                $scope.lunbo.currentId = 1;
            }
            else {
                $scope.lunbo.currentId++;
            }
        }, 2000);
    }

// })

module.exports=WelcomeCtrl;